<template>
    <h1>权益添加</h1>
    <div>
        <table border="1">
            <tbody>
                <tr>
                    <th>权益名称</th>
                    <th>
                        <input type="text" v-model="data.RightName">
                    </th>
                </tr>
                <tr>
                    <th>描述</th>
                    <th>
                        <input type="text" v-model="data.RightDes">
                    </th>
                </tr>
                <tr>
                    <th>状态</th>
                    <th>
                        <input type="checkbox" v-model="data.RightState">选中启用不选择禁用
                    </th>
                </tr>
                <tr>
                    <th>
                        <input type="button" value="添加" @click="Add">
                    </th>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import axios from 'axios';
import { reactive, ref, renderSlot } from 'vue';
import { useRouter } from 'vue-router';
import { onMounted } from 'vue';

const data=ref({
    "RightId": 0,
  "RightName": "",
  "RightDes": "",
  "RightState": true,
  "RightDelete": true
})

const rou=useRouter();

const Add=()=>{
    axios.post("https://localhost:7147/api/Member/AddRightsss",data.value).then(res=>{
        if(res.data>0){
            alert('添加权益成功')
            rou.push({path:'/ShowRightView'})
        }
        else if(res.data==-1){
            alert('权益名称重复')
        }
        else{
            alert('失败')
        }
    })
}




</script>

